package com.lbb.simple.demo.controller

import com.lbb.http.GsonUtil
import com.lbb.http.HttpUtil
import com.lbb.http.call.CallBack
import com.lbb.mvp.presenter.BasePresenter
import com.lbb.mvp.view.BaseView
import com.lbb.simple.demo.bean.Fm
import com.lbb.simple.demo.http.Api

class FmController {
    class FmPresenter(view: FmView) : BasePresenter<FmView>(view) {
        override fun onCreate() {
            super.onCreate()
            getFmRecommend()
        }

        fun getFmRecommend() {
           view?.showLoadingFmRecommend()
            HttpUtil.get(Api.fm_recommend, null, object : CallBack<String> {
                override fun complete() {

                }

                override fun success(string: String) {
                    view?.setFmRecommend(GsonUtil.toList(string,Fm::class.java))
                }

                override fun error(string: String) {
                    view?.showErrorFmRecommend()
                }

            })
        }
    }

    interface FmView : BaseView {
        fun showLoadingFmRecommend()
        fun showErrorFmRecommend()
        fun setFmRecommend(list: List<Fm>)
    }
}